#! /bin/bash
export LANG=zh_CN.UTF-8
HIVE_HOME=/usr/bin/hive


${HIVE_HOME} -S -e "
-- 线索申诉信息表：dim_customer_appeal
INSERT OVERWRITE TABLE edu_online_dwd.dim_customer_appeal PARTITION (start_date)
SELECT
    id,
    customer_relationship_first_id,
    employee_id,
    employee_name,
    employee_department_id,
    employee_tdepart_id,
    appeal_status,
    audit_id,
    audit_name,
    audit_department_id,
    audit_department_name,
    audit_date_time,
    create_date_time,
    update_date_time,
    deleted,
    tenant,
    '9999-99-99' AS end_date,
    dt AS start_date
FROM edu_online_ods.customer_appeal;


-- 客户静态信息表：dim_customer
INSERT OVERWRITE TABLE edu_online_dwd.dim_customer PARTITION (start_date)
SELECT
    id,
    customer_relationship_id,
    create_date_time,
    update_date_time,
    deleted,
    name,
    idcard,
    birth_year,
    gender,
    phone,
    wechat,
    qq,
    email,
    area,
    leave_school_date,
    graduation_date,
    bxg_student_id,
    creator,
    origin_type,
    origin_channel,
    tenant,
    md_id,
    '9999-99-99' AS end_date,
    dt AS start_date
FROM edu_online_ods.customer;


-- 校区信息表：dim_itcast_school
INSERT OVERWRITE TABLE edu_online_dwd.dim_itcast_school
SELECT
*
FROM edu_online_ods.itcast_school;


-- 学科信息表：dim_itcast_subject
INSERT OVERWRITE TABLE edu_online_dwd.dim_itcast_subject
SELECT
*
FROM edu_online_ods.itcast_subject;


-- 员工信息表：dim_employee
INSERT OVERWRITE TABLE edu_online_dwd.dim_employee
SELECT
*
FROM edu_online_ods.employee;


-- 员工部门表：dim_scrm_department
INSERT OVERWRITE TABLE edu_online_dwd.dim_scrm_department
SELECT
*
FROM edu_online_ods.scrm_department;
"